<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
  <!-- 
       作用域插槽：
            父组件替换插槽的标签，但内容由子组件来提供 
   -->

    <div id="app">
      
      <cpn></cpn>
      <cpn>
          <!-- 目的是获取子组件的planguage -->
          <template slot-scope="slot">
                <span v-for="item in slot.data">{{item}} - </span>
          </template>
      </cpn>
      <cpn>
        <!-- 目的是获取子组件的planguage -->
        <template slot-scope="slot">
              <!-- <span v-for="item in slot.data">{{item}} *  </span> -->
              <span>{{slot.data.join(" * ")}}</span>
        </template>
    </cpn>
      <!-- <cpn v-show="isShow"></cpn> -->
     
    </div>
    <template id="cpn">
        <div>
            <slot :data="planguages">
                <ul>
                    <li v-for="item in planguages">{{item}}</li>
                </ul>
            </slot>
            
        </div>
    </template>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                message:'你好呀！',
                isShow:true
            },
            components:{
                cpn:{
                    template:"#cpn",
                    data(){
                        return{
                            planguages:["javascript","c#","c++","Go","Python","swift"]
                        }
                    },
                    // join 可以把数组转字符串，然后拼接
                    // created(){
                    //     this.planguages.join("-")
                    // }
                }
            }
        })
    </script>
</body>
</html>